Repository navigation
fix(aggregator): serve self-unregistering /sw.js kill switch - #1434
Conversation
The dashboard origin fronted the opencode web app until 2026-10-27; browsers that visited it then still hold opencode's Workbox service worker, which serves the opencode shell from cache. A tiny valid worker at /sw.js unregisters itself on activate and reloads open tabs, so stranded browsers heal on their next update check.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d870a21b7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.addEventListener('activate', async () => { | ||
| try { await self.registration.unregister(); } catch {} | ||
| const cs = await self.clients.matchAll({ type: 'window' }); | ||
| for (const c of cs) { try { c.navigate(c.url); } catch {} } |
There was a problem hiding this comment.
Extend the activation event through cleanup and navigation
When this replacement worker activates for a browser displaying the stale opencode shell, the async listener's returned promise does not extend the activation event. The browser can therefore terminate the worker while unregister() or matchAll() is pending, leaving the open tabs unreloaded; the service-worker lifetime specification explicitly permits termination when there is no event to handle. Pass the entire cleanup operation to the activation event's waitUntil() and await the navigation promises as well, so the kill switch keeps the worker alive until its recovery work completes.
Useful? React with 👍 / 👎.
Why
Until 2026-10-27 the dashboard origin (https://amd-6.raptor-pumpkinseed.ts.net, the laptop tailnet-serve clean address) fronted the opencode web app. Browsers that visited it then -- Drew's included -- registered opencode's Workbox service worker for that origin. The origin now serves the dashboard, but the stranded worker keeps answering from its precache, so those browsers see the opencode shell instead of the dashboard. The dashboard origin returned 404 for /sw.js, so the registration never updated.
What
GET /sw.js on the aggregator now returns a tiny, dependency-free service worker that calls skipWaiting on install and, on activate, unregisters itself and navigates controlled window clients back to their current URL. On the browser's next service-worker update check it installs, removes the registration, and open tabs reload into the dashboard -- no user action needed. Fresh browsers that ever fetch it are unaffected (it removes itself immediately).
Verification (on the laptop)
Context: code#1363 (serve remap). The opencode origin (:4096) keeps serving its own real /sw.js -- untouched.
Need help on this PR? Tag
@codesmith-botwith what you need.